package top.aiprogram.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import top.aiprogram.dao.UserMapper;
import top.aiprogram.entity.User;

@Service
public class UserServiceImpl implements UserService{


    @Autowired
    private UserMapper userMapper;


    @Override
    @Transactional(propagation = Propagation.REQUIRED)//可设置回滚级别(rollback=exception.class)--异常回滚
                //事务隔离机制有7种
                //spring事务传播(propagation = Propagation.REQUIRED)--默认
                //效果是：如果上下文存在事务，就加入事务执行，没有则创建新事务
    public void creatUser(User user) {
        userMapper.deleteByPrimaryKey(user.getId());
    }
}
